﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Supermarket.Dal;

namespace Supermarket.Bll
{
    public class ProductManager
    {
        public static void CreateProduct(string productName, decimal productPrice, int companyId, int categoryId, int measureId)
        {
            Product product = new Product();
            product.ProductName = productName;
            product.ProductPrice = productPrice;
            product.CompanyId = companyId;
            product.CategoryId = categoryId;
            product.MeasureId = measureId;

            ProductDB.CreateProduct(product);
        }

        public static List<object> GetAllProducts()
        {
            List<object> products = ProductDB.GetAllProducts();            
            return products;
        }

        public static Product GetItem(int productId)
        {
            Product product = ProductDB.GetItem(productId);

            return product;
        }

        public static void Update(int id, string productName, decimal productPrice, int companyId, int categoryId, int measureId)
        {
            Product product = new Product();
            product.ProductId = id;
            product.ProductName = productName;
            product.ProductPrice = productPrice;
            product.CompanyId = companyId;
            product.CategoryId = categoryId;
            product.MeasureId = measureId;

            ProductDB.Update(product);
        }

        public static List<object> GetAvailableProducts()
        {
            List<object> products = ProductDB.GetAvailableProducts();
            return products;
        }
    }
}
